<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>    
    <div id="allmap"></div>
</body>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=amX9OmZ5XWiQToADtF9ogqcxmUuTGVrg"></script>
<script>
const geolocation = new BMap.Geolocation();
geolocation.getCurrentPosition(function(res){
	if(this.getStatus() == window.BMAP_STATUS_SUCCESS){
        console.log(res.address);     
		alert('您的位置：'+res.point.lng+','+res.point.lat);
	} 
});
</script>
</html>